
package cn.bluethink.eguan.model.core;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import cn.bluethink.eguan.utils.DateTimeSerializer;

/**
 * @title 通用性任务
 * @Copyright 苏州中科蓝迪公司所有(c)2016-2021
 * @version 0.1
 *
 * @note 修订历史： （1）liuxn于2018年8月14日构建初始版本0.1
 *       （2）giszyj@126.com于2018年10月07日增加用户完成时间属性
 */
public class EgTask extends EgObject {

    /**
     * 任务描述
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String content = null;

    /**
     * 标签列表（不同标签用逗号隔开，会被进行持久化，用于过滤查询）
     */
	@JsonInclude(JsonInclude.Include.NON_NULL)
    private String tags = null;

    /**
     * 优先级
     */
    private Integer priority;

    /**
     * 周期标识
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private EgCycleType cycle = null;

    /**
     * 任务结果的类型
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private EgOType rtype = null;

    /**
     * 任务状态（未开始，进行中，已延误，已完成）
     */
    private Integer status;

    /**
     * 任务从什么开始
     */
    @JsonSerialize(using = DateTimeSerializer.class)
    private Date btime;

    /**
     * 计划任务完成（或结束）的时间
     */
    @JsonSerialize(using = DateTimeSerializer.class)
    private Date etime;

    /**
     * 任务发布者，WHO
     */
    private EgUser cuser;

    /**
     * 该任务创建或更新任务信息的时间，WHEN
     */
    @JsonSerialize(using = DateTimeSerializer.class)
    private Date utime;

    /**
     * 在哪个对象处发布的任务，为空表示在江湖中发布的任务，WHERE
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private EgObject pos = null;

    /**
     * 用户做任务的准确完成的时间，和etime一起判断是否延误
     */
    private Date ftime;

    /**
     * @since 1.0.0
     * @roseuid 5B6D1B1402FC
     */
    public EgTask() {

    }

    public EgTask(Long tid, String name, String content, EgOType otype) {
        super(tid, name, otype);
        this.content = content;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getTags() {
        return tags;
    }

    public void setTags(String tags) {
        this.tags = tags;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public Date getUtime() {
        return utime;
    }

    public void setUtime(Date utime) {
        this.utime = utime;
    }

    public Date getBtime() {
        return btime;
    }

    public void setBtime(Date btime) {
        this.btime = btime;
    }

    public Date getEtime() {
        return etime;
    }

    public void setEtime(Date etime) {
        this.etime = etime;
    }

    public EgUser getCuser() {
        return cuser;
    }

    public void setCuser(EgUser cuser) {
        this.cuser = cuser;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public EgObject getPos() {
        return pos;
    }

    public void setPos(EgObject pos) {
        this.pos = pos;
    }

    public EgCycleType getCycle() {
        return cycle;
    }

    public void setCycle(EgCycleType cycle) {
        this.cycle = cycle;
    }

    public EgOType getRtype() {
        return rtype;
    }

    public void setRtype(EgOType rtype) {
        this.rtype = rtype;
    }

    public Date getFtime() {
        return ftime;
    }

    public void setFtime(Date ftime) {
        this.ftime = ftime;
    }

    @Override
    public boolean isValidate() {
        boolean idflag = super.isValidate();
        String name = this.getName();
        return !(name == null || name.trim().length() == 0) && idflag;
    }
}
